var form = document.forms[0];
form.onsubmit = ()=>{
  fetch("api/user/login",{
    method:"post",
    cache: 'no-cache',
    credentials:"include",
    headers:{"content-type":"application/x-www-form-urlencoded"},
    body:new URLSearchParams(new FormData(form)).toString()}
  ).then(r=>r.json()).then(data=>{
    console.info(data);
    if(data.ok){
      //登录成功  
      alert("登录成功");
      location="./"
    }else{
      //登录失败
      alert(data.message);
    }
  }).catch(e=>{
    alert("网络错误");
  });
  return false;
}